
package com.starshineworks.servlets;

import com.starshineworks.entities.*;
import com.starshineworks.util.Util;

import java.util.Map;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpSession;

@WebServlet(name = "Info", urlPatterns = {"/Info"})
public class Info extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        // This is a page that require more than target jsp and session
        HttpSession sess = request.getSession(false);
        if (sess != null) {
            Integer uId = (Integer)sess.getAttribute("uId");
            if (uId != null) {
                UserinfoE ui = (UserinfoE)UserinfoE.retrieveByUser(uId);
                Map<String,Object> map = ui.getFieldNamesAndValues();
                sess.setAttribute("userinfo", map);
            }
        }
        Util.showForm(request, response, "Info", true, false, false); 
    }

}
